/**
 * @param {*} arr 原数组
 * @param {*} ids 需要移动到数组开头的id列表
 * @returns 返回重组后的列表数据
 * <span v-html="$sunSetBtn('ban', '删除', '#FF0000')" />
 */
export function $setBtn(type, title, color) {
  // 查询 check 简写
  if (type === 'CK') {
    return `
      <div
        style="
          color: ${color};
          display: inline-block;
          padding: 7px 15px;
          font-size: 12px;
          cursor: pointer;
          line-height: 1;
        ">
          ${title}
      </div>
    `
  }
  // 功能 function 简写
  if (type === 'fun') {
    return `
      <div
        style="
          color: #FFFFFF;
          display: inline-block;
          padding: 7px 15px;
          font-size: 12px;
          border-radius: 3px;
          cursor: pointer;
          border: 1px solid ${color};
          background-color: ${color};
          line-height: 1;
        ">
          ${title}
      </div>
    `
  }
  // 镂空禁用
  if (type === 'ban') {
    return `
      <div
        style="
          color: ${color};
          display: inline-block;
          padding: 7px 15px;
          font-size: 12px;
          border-radius: 3px;
          cursor: pointer;
          border: 1px solid ${color};
          background-color: #FFFFFF;
          line-height: 1;
        ">
          ${title}
      </div>
    `
  }
  // readOnly 简读加粗
  if (type === 'RO') {
    return `
      <div
        style="
          color: ${color};
          display: inline-block;
          padding: 7px 15px;
          font-weight: bold;
          font-size: 12px;
          cursor: pointer;
          line-height: 1;
        ">
          ${title}
      </div>
    `
  }
}

/**
 * 设置按钮是否可点击
 * @param {*} btn 按钮对象数据
 * @param {*} type 按钮类型 disabled： 教师资料审核 name： group 操作按钮
 * @param {*} isRecycleBin 是否是回收站
 * @returns true false
 */
export function $setDelBtn(btn, type, isRecycleBin) {
  if (type === 'disabled') {
    console.log('btn', btn)
    if (!isRecycleBin) return false
    if (isRecycleBin) {
      if (btn.model === 'look_information' ||
        btn.model === 'delete' ||
        (btn.name === '评审明细' && btn.model === 'evaluation_result')
      ) {
        return false
      } else {
        return true
      }
    }
    // || btn.model === 'audit_information'
    // if (isRecycleBin && (btn.model === 'look_information' || btn.model === 'delete')) {
    //   return false
    // } else {
    //   return true
    // }
  }
  if (type === 'name') {
    if (isRecycleBin && btn.model === 'delete') {
      return '恢复'
    } else {
      return btn.name
    }
  }
}
